package Presentacion.Ventas.RapiVentas;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.JLabel;

import java.awt.Font;

import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

public class RetiraEnCtaCte extends JDialog {

	private final JPanel contentPanel = new JPanel();
	private static JTextField tfRetira;
	private RapiVentas obj;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
//		try {
			RapiVentas obj = null;
			RetiraEnCtaCte dialog = new RetiraEnCtaCte(obj);
//			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
//			dialog.setVisible(true);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
	}

	/**
	 * Create the dialog.
	 */
	public RetiraEnCtaCte(RapiVentas obj) {
		setTitle("Cta.Cte.");
		this.obj = obj;
		try {
			setBounds(100, 100, 288, 171);
			getContentPane().setLayout(new BorderLayout());
			contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
			getContentPane().add(contentPanel, BorderLayout.CENTER);
			contentPanel.setLayout(null);
			
			JLabel lblRetiraACuenta = new JLabel("Retira a cuenta");
			lblRetiraACuenta.setFont(new Font("Tahoma", Font.BOLD, 14));
			lblRetiraACuenta.setBounds(10, 11, 138, 24);
			contentPanel.add(lblRetiraACuenta);
			
			JSeparator separator = new JSeparator();
			separator.setBounds(10, 37, 250, 2);
			contentPanel.add(separator);
			
			tfRetira = new JTextField();
			tfRetira.setHorizontalAlignment(SwingConstants.CENTER);
			tfRetira.setFont(new Font("Tahoma", Font.PLAIN, 15));
			tfRetira.setBounds(10, 46, 250, 33);
			contentPanel.add(tfRetira);
			tfRetira.setColumns(10);
			{
				JPanel buttonPane = new JPanel();
				buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
				getContentPane().add(buttonPane, BorderLayout.SOUTH);
				{
					JButton okButton = new JButton("Aceptar");
					okButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent arg0) {
							guardar();
						}
					});
					okButton.setActionCommand("OK");
					buttonPane.add(okButton);
					getRootPane().setDefaultButton(okButton);
				}
				{
					JButton cancelButton = new JButton("Cancel");
					cancelButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							cancelar();
						}
					});
					cancelButton.setActionCommand("Cancel");
					buttonPane.add(cancelButton);
				}
			}
			
			this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			this.setVisible(true);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	public void cancelar(){
		dispose();
	}
	
	public void guardar(){
		obj.setRetiraEnCtaCte(this.tfRetira.getText());
		cancelar();
	}
}
